package com.acme.task3;

public class Task3Arrays {
    private static int[] arr;

    private static void task1() {
    	for (int i = 1; i <= 50; i++) {
    		System.out.println(i);
    	}
    }

    private static void task2() {
    	for (int i = 1; i <= 50; i++) {
    		if (i % 3 == 0) {
    			System.out.format("number %d divisible by 3%n", i);
    		}
    	}
    }

    private static void task3() {
    	java.io.Console console = System.console();
    	
    	if (console == null) {
    		System.out.println("There is no console");
    		return;
    	}
    	
    	int n = Integer.parseInt(console.readLine("Input n: "));
        arr = new int[n];
        for (int i = 0; i < n; arr[i] = i + 1, i++);
        
        System.out.println("Average value of array: " + avg());
    }

    private static double avg() {
    	if (arr == null || arr.length == 0) {
    		return 0.0;
    	}
    	
    	double sum = 0.0;
        for (int i = 0; i < arr.length; sum += arr[i], i++);
        
        return sum /= arr.length;
    }

    public static void main(String[] args) {
    	task1();
    	task2();
    	task3();
    }
}

